314001c5b782293db5e9c35e99afb688ced2a54f,clc/modules/block-storage-common/src/main/java/com/eucalyptus/blockstorage/entities/DirectStorageInfo.java,DirectStorageInfo,getStorageInfo,#,197
Before Change
public static DirectStorageInfo getStorageInfo() {
DirectStorageInfo conf = null;
TransactionResource tran = Entities.transactionFor(DirectStorageInfo.class);
try {
conf = Entities.uniqueResult(new DirectStorageInfo(StorageProperties.NAME));
// EUCA-3597 Introduced a new column for timeout. Ensure that its populated in the DB the first time
if (null == conf.getTimeoutInMillis()) {
conf.setTimeoutInMillis(StorageProperties.timeoutInMillis);
Entities.merge(conf);
}
tran.commit();
}
catch ( NoSuchElementException e ) {
LOG.warn("Failed to get storage info for: " + StorageProperties.NAME + ". Loading defaults.");
conf = new DirectStorageInfo(StorageProperties.NAME,
StorageProperties.iface,
StorageProperties.storageRootDirectory,
StorageProperties.zeroFillVolumes,
StorageProperties.timeoutInMillis);
Entities.persist(conf);
tran.commit();
}
catch (Exception t) {
LOG.error("Unable to get storage info for: " + StorageProperties.NAME);
tran.rollback();
return new DirectStorageInfo(StorageProperties.NAME,
StorageProperties.iface,
StorageProperties.storageRootDirectory,
After Change
public static DirectStorageInfo getStorageInfo() {
DirectStorageInfo conf = null;
try {
conf = Transactions.find(new DirectStorageInfo());
} catch (Exception e) {
LOG.warn("Direct storage information for " + StorageProperties.NAME + " not found. Loading defaults.");
try {
conf = Transactions.saveDirect(new DirectStorageInfo(StorageProperties.NAME, StorageProperties.iface, StorageProperties.storageRootDirectory,
StorageProperties.zeroFillVolumes, StorageProperties.timeoutInMillis));
} catch (Exception e1) {
try {
conf = Transactions.find(new DirectStorageInfo());
} catch (Exception e2) {
LOG.warn("Failed to persist and retrieve DirectStorageInfo entity");
}
}
}
if (conf == null) {
conf = new DirectStorageInfo(StorageProperties.NAME, StorageProperties.iface, StorageProperties.storageRootDirectory,
StorageProperties.zeroFillVolumes, StorageProperties.timeoutInMillis);
}